package nuc.ss.wl.controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class UserServlet extends BaseServlet {

    protected void login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        String password = request.getParameter("password");
        if ("zbdx".equals(id)&&"181300411".equals(password)) {
            request.getSession().setAttribute("id", id);
            request.getRequestDispatcher("pages/user/login_success.jsp").forward(request, response);
        } else {
            request.setAttribute("message", "登录账号或密码错误！");
            request.setAttribute("id", id);
            request.getRequestDispatcher("pages/user/login.jsp").forward(request, response);
        }
    }

    protected void logout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getSession().invalidate();
        response.sendRedirect(request.getContextPath());
    }

}
